<template>
  <div class="app-container flex-col minH">
    <div class="topline w100p bgwhite pt20 pb10 radius10 pl10 pr20 justify-between">
      <div class="align-center flex-wrap">
        <el-input v-model="uid" style="width: 280px" placeholder="搜尋用戶UID..." :prefix-icon="Search" class="mr10 mb10 search" />
        <el-input v-model="touid" style="width: 280px" placeholder="搜尋陪玩UID..." :prefix-icon="Search" class=" mr10 mb10 search" />
        <div class="align-center mb10">
          <el-date-picker v-model="start" type="datetime" placeholder="开始时间" value-format="YYYY-MM-DD HH:mm:ss" />
          <span class="plr10 clr9fa">--</span>
          <el-date-picker v-model="end" type="datetime" placeholder="结束时间" value-format="YYYY-MM-DD HH:mm:ss" />
        </div>

      </div>
      <div class="noshrink mb10">
        <el-button class="btn2" @click="search()">查詢</el-button>
        <el-button class="btn1" @click="reset()">重置</el-button>
      </div>
    </div>
    <div class="bgblueg ptb20 radius10 w100p mt15 pl10 bold clr3c4">
      打賞總金額：{{ total_money }}元

    </div>
    <div class="mt15 radius10 hidden pb15 flex1 bgwhite  flex-col w100p">
      <div class="flex1 w100p ">
        <el-table :data="tableData" style="width: 100%" cell-class-name="tbcell" header-cell-class-name="hdcell">
          <el-table-column prop="user" label="用戶訊息">
            <template #default="scope">
              <span @click="showUser(scope.row.user.id)"> {{ scope.row.user.phone }}(ID:{{ scope.row.user.id }})</span>
            </template>
          </el-table-column>
          <el-table-column prop="touser" label="陪玩訊息">
            <template #default="scope">
              <span @click="showUser(scope.row.touser.id)">{{ scope.row.touser.phone }}(ID:{{ scope.row.touser.id }})</span>
            </template>
          </el-table-column>
          <el-table-column prop="total_price" label="總金額" sortable />
          <el-table-column prop="created_at" label="創建時間" sortable width="200" />
        </el-table>
      </div>
      <div class="plr20 mlauto mt20">
        <el-pagination v-model:current-page="currentPage" prev-text="上一頁" next-text="下一頁" :default-page-size="15" :small="small" :disabled="disabled" :background="true" layout="prev, pager, next, jumper" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
      </div>

    </div>
  </div>
</template>

<script setup>
import { Search } from '@element-plus/icons-vue'
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router';
import { rewardList } from '@/api/order.js'
import { inject } from 'vue';
const showUser = inject('showUser');
onMounted(() => {
  getRewardList()
})
const uid = ref('')
const touid = ref('')
const start = ref('')
const end = ref('')

// 打赏记录
const getRewardList = () => {
  rewardList({
    page: currentPage.value,
    uid: uid.value,
    touid: touid.value,
    start: start.value,
    end: end.value
  }).then((res) => {
    console.log('打赏记录', res)
    tableData.value = res.data.data
    total.value = res.data.total
    total_money.value = res.total
  })
}
const total_money = ref('')
const input2 = ref('')
const value = ref('')
const value1 = ref('')
const value2 = ref('')
const dialogTableVisible = ref(false)
const dialogType = ref(1)
const dialogShow = (type) => {
  console.log('dialog----show----')
  dialogType.value = type
  dialogTableVisible.value = true
}
const search = () => {
  getRewardList()
}
const reset = () => {
  uid.value = ''
  touid.value = ''
  start.value = ''
  end.value = ''
  getRewardList()
}
const tableData = ref([])
const currentPage = ref(1)
const total = ref(0)
const handleSizeChange = (val) => {
  console.log(`${val} items per page`)
}
const handleCurrentChange = (val) => {
  console.log(`current page: ${val}`)
  getRewardList()
}
const router = useRouter()


</script>

<style lang="scss" scoped>
.search {
  overflow: hidden;
  border-radius: 10px !important;
  // padding: 5px 0px;
}
</style>
<style></style>
 